package com.flame.application.controller;

import com.flame.application.entity.bean.Book;
import com.flame.application.service.BookService;
import com.flame.application.service.RagService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author Jflame
 * @version 1.0.0
 * @since 2025/8/15
 */
@RestController
public class BookController {
    @Resource
    private BookService bookService;

    @Resource
    private RagService ragService;

    @GetMapping("/list")
    public String list() {

        return "";
    }

    @PostMapping("/upload")
    public String upload(@RequestParam("file")MultipartFile file) {
        String bookId = bookService.upload(file);
        Book book = bookService.getById(bookId);
        ragService.embedToVectorStore(book);
        return "success";
    }
}
